package org.com.service.impl;

import org.com.mapper.ChatMessageMapper;
import org.com.pojo.ChatMessage;
import org.com.service.ChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ChatServiceImpl implements ChatService {
    
    @Autowired
    private ChatMessageMapper chatMessageMapper;
    
    @Override
    public boolean sendMessage(ChatMessage message) {
        return chatMessageMapper.insert(message) > 0;
    }
    
    @Override
    public List<ChatMessage> getChatHistory(Integer userId1, Integer userId2) {
        return chatMessageMapper.getChatHistory(userId1, userId2);
    }
    
    @Override
    public boolean markAsRead(Integer toUserId, Integer fromUserId) {
        return chatMessageMapper.markAsRead(toUserId, fromUserId) > 0;
    }
    
    @Override
    public int getUnreadCount(Integer toUserId) {
        return chatMessageMapper.getUnreadCount(toUserId);
    }
} 